package contest.sweek200;

/**
 * LeetCode1534. 统计好三元组
 * @author code_yc
 * @version 1.0
 * @date 2020/8/3 22:16
 */
public class Solution1 {

    public int countGoodTriplets(int[] arr, int a, int b, int c) {
        int ans = 0;
        int n = arr.length;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                for (int k = j + 1; k < n; k++) {
                    if (Math.abs(arr[i] - arr[j]) <= a && Math.abs(arr[j] - arr[k]) <= b && Math.abs(arr[i] - arr[k]) <= c)
                        ans++;
                }
            }
        }
        return ans;
    }
}
